package com.study.hadoop.mapreduce.writable;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

/**
 * @Author huang
 * @Date 2022/1/3 13:59
 * @Version 1.0
 */
public class FlowDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        //1.获取job
        Configuration config = new Configuration();
        Job job = Job.getInstance(config);
        //2.设置jar
        job.setJarByClass(FlowDriver.class);
        //3.设置mapper和reducer
        job.setMapperClass(FlowMapper.class);
        job.setReducerClass(FlowReducer.class);
        //4.设置mapper输出类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(FlowBean.class);
        //5.设置最终输出类型
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(FlowBean.class);
        //6.设置文件输入输出路径
        FileInputFormat.setInputPaths(job, new Path("D:\\生活\\study\\hadoop\\资料\\11_input\\inputflow\\phone_data.txt"));
        FileOutputFormat.setOutputPath(job, new Path("D:\\生活\\study\\hadoop\\系统\\test"));
        //7.退出
        boolean result = job.waitForCompletion(true);
        System.exit(result ? 0 : 1);
    }
}
